<?php



namespace App\Services\Order\Models;

use App\Services\Member\Models\User;
use App\Services\Other\Models\UserPrize;
use App\Services\Order\Models\UserRedeemCode;
use Illuminate\Database\Eloquent\Model;


class RedeemCode extends Model
{


    protected $table = 'redeem_codes';

    protected $fillable = [
        'user_id', 'title','expired_days','start_time','end_time','title','code',

        // 可使用次数,0为不限制
        'use_times','coupon_count','claim_count','minimum_purchase','type','reduce_count','discount'

    ];
    public function redeems()
    {
        return $this->hasmany(UserRedeemCode::class, 'user_redeem_id');
    }

    public function products()
    {
        return $this->hasmany(RedeemCodeProduct::class, 'redeem_code_id');
    }
    public function claimers()
    {
        return $this->belongsToMany(User::class,'user_redeem_codes','redeem_code_id','user_id');
    }


}
